package com.focus.xyz.core.common.generator;

import com.focus.xyz.core.utils.Constants;
import com.focus.xyz.core.utils.prop.ConfigPropInfo;
import org.apache.commons.lang.StringUtils;


public class DriverFactory {
	private static final String ORACLE = "oracle.jdbc.OracleDriver";
	private static final String MYSQL = "com.mysql.jdbc.Driver";
	
	public static IDriverSV driveMySql(){
		return new DataDriver(MYSQL, ConfigPropInfo.DB_URL, ConfigPropInfo.DB_USERNAME, ConfigPropInfo.DB_PASS);
	}
	
	public static IDriverSV driveOracle(){
		return new DataDriver(ORACLE, ConfigPropInfo.DB_URL, ConfigPropInfo.DB_USERNAME, ConfigPropInfo.DB_PASS);
	}
	
	public static IDriverSV getDriver(String dbType){
		if(StringUtils.isNotBlank(dbType)){
			if(Constants.ORACLE.equals(dbType)){
				return new DataDriver(ORACLE, ConfigPropInfo.DB_URL, ConfigPropInfo.DB_USERNAME, ConfigPropInfo.DB_PASS);
			}
			if(Constants.MYSQL.equals(dbType)){
				return new DataDriver(MYSQL, ConfigPropInfo.DB_URL, ConfigPropInfo.DB_USERNAME, ConfigPropInfo.DB_PASS);
			}else{
				return null;
			}
		}else{
			return new DataDriver(ORACLE, ConfigPropInfo.DB_URL, ConfigPropInfo.DB_USERNAME, ConfigPropInfo.DB_PASS);
		}
	}

}
